home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
8_6.lha
/
8_6
/
istream.h
< prev
next >
Wrap
Text File
|
1993-08-08
|
2KB
|
86 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
lass istream
friend ostream;
streambuf* bp;
ostream* tied_to;
char skipws; // if non-null, automaticly skip whitespace
short state;
friend void eatwhite (istream&);
ublic:
int skip(int i) { int ii=skipws; skipws=i; return ii; }
/*
formatted input: >> skip whitespace
*/
istream& operator>>(char*); // string
istream& operator>>(char&); // single character
istream& operator>>(short&);
istream& operator>>(int&);
istream& operator>>(long&);
istream& operator>>(float&);
istream& operator>>(double&);
istream& operator>>(streambuf&);
istream& operator>>(whitespace&); // skip whitespace
/ istream& operator>>(common&);
/*
raw input: get's do not skip whitespace
*/
istream& get(char*, int, char ='\n'); // string
istream& get(streambuf& sb, char ='\n');
istream& get(char& c) // single character
{
int os = skipws;
skipws = 0;
*this >> c;
skipws = os;
return *this;
}
istream& putback(char c);
ostream* tie(ostream* s) { ostream* t = tied_to; tied_to = s; return t; }
operator void*(){ return _eof<state?0:this; }
int operator!() { return _eof<state; }
int eof() { return state&_eof; }
int fail() { return _eof<state; }
int bad() { return _fail<state; }
int good() { return state==_good; }
void clear(state_value i =0) { state=i; }
int rdstate() { return state; }
/ char* bufptr() { return bp->base; }
istream(streambuf* s, int sk =1, ostream* t =0) // bind to buffer
{
state = 0;
skipws = sk;
tied_to = t;
bp = s;
}
istream(int size, char* p, int sk =1) // bind to string
{
state = 0;
skipws = sk;
tied_to = 0;
bp = new streambuf();
if (p == 0) p = new char[size];
bp->setbuf(p, size, size);
}
istream(FILE *fp, int sk =1, ostream* t =0) // bind to file
{
state = 0;
skipws = sk;
tied_to = t;
bp = new filebuf(fp);
}
;